using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Newtonsoft.Json;

namespace aPCSuite
{
    enum SMS_TYPE
    {
        SEND,
        RECEIVE,
    }

    enum SMS_STATUS
    {
        NEW, 
        DELETE,
        READ,
        UNREAD
    }

    public class SmsObject
    {
        public int id;
        SMS_TYPE type;
        public string date;
        public string body;
        SMS_STATUS status;
    }

    public class SmsData
    {
        //SmsObject[] smslist;
        public List<SmsObject> smslist;
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            /*string json = @"{
              'id': 100,
              'type': 0,
              'date':'1995-4-7T00:00:00',
              'body':'my test',
              'status':0
            }";/**/

            string json = @"{
                'smslist':[
                    {
                      'id': 100,
                      'type': 0,
                      'date':'1995-4-7T00:00:00',
                      'body':'my test',
                      'status':0
                    }, 
                    {
                      'id': 101,
                      'type': 1,
                      'date':'1995-4-7T00:00:00',
                      'body':'my test 1',
                      'status':1
                    }
                ]
            }";

            SmsData smsData = DeserializeSmsObject(json);

            string sjson = SerializeSmsObject(smsData);
        }

        public SmsData DeserializeSmsObject(string strJson)
        {
            //SmsObject smsObj = JsonConvert.DeserializeObject<SmsObject>(strJson);
            SmsData smsData = JsonConvert.DeserializeObject<SmsData>(strJson);

            Console.WriteLine("json testing");

            return smsData;
        }

        public string SerializeSmsObject(SmsData obj)
        {
            string json = JsonConvert.SerializeObject(obj);

            Console.WriteLine("json : " + json);

            return json;
        }
    }
}